#include "vertexarrayobject.h"

VertexArrayObject::VertexArrayObject () {
    this->setClearMask(0);
    
    this->generate();
    this->bind();
}

VertexArrayObject::~VertexArrayObject () {}

void VertexArrayObject::generate () {
    glGenVertexArrays(1, &this->id);
}

void VertexArrayObject::bind () {
    glBindVertexArray(this->id);
}

void VertexArrayObject::drawElements () {
    this->clearBuffers();
    glDrawElements(this->drawMode, this->drawCount, this->drawType, this->drawIndices);
}

void VertexArrayObject::setDrawElements (
    GLenum mode, 
    GLsizei count, 
    GLenum type, 
    const GLvoid * indices
) {
    this->drawMode = mode;
    this->drawCount = count;
    this->drawType = type;
    this->drawIndices = indices;
}    

void VertexArrayObject::setClearMask(GLbitfield mask) {
    this->clearMask = mask;
}
        
void VertexArrayObject::clearBuffers () {
    glClear(this->clearMask);
}